﻿function PageLoad() {
    $("#divInvMain").fadeIn("slow");
}

function link(o) {
    document.getElementById("nb").className = "";
    document.getElementById("m").className = "";
    document.getElementById("r").className = "";
    document.getElementById("me").className = "";
    document.getElementById("a").className = "";
    o.className = "active";
    document.getElementById("lostfocus").focus();
    switch (o.id) {
        case "nb":
            $("#divMisa")[0].style.display = "none";
            $("#divRecepcion")[0].style.display = "none";
            $("#divMesa")[0].style.display = "none";
            $("#divAsistencia")[0].style.display = "none";
            $("#divInvMain").fadeIn("slow");
            break;
        case "m":
            $("#divInvMain")[0].style.display = "none";
            $("#divRecepcion")[0].style.display = "none";
            $("#divMesa")[0].style.display = "none";
            $("#divAsistencia")[0].style.display = "none";
            $("#divMisa").fadeIn("slow");
            break;
        case "r":
            $("#divMisa")[0].style.display = "none";
            $("#divInvMain")[0].style.display = "none";
            $("#divMesa")[0].style.display = "none";
            $("#divAsistencia")[0].style.display = "none";
            $("#divRecepcion").fadeIn("slow");
            break;
        case "me":
            $("#divInvMain")[0].style.display = "none";
            $("#divMisa")[0].style.display = "none";
            $("#divRecepcion")[0].style.display = "none";
            $("#divAsistencia")[0].style.display = "none";
            $("#divMesa").fadeIn("slow");
            break;
        case "a":
            $("#divInvMain")[0].style.display = "none";
            $("#divMisa")[0].style.display = "none";
            $("#divRecepcion")[0].style.display = "none";
            $("#divMesa")[0].style.display = "none";
            $("#divAsistencia").fadeIn("slow");
            break;
    }
}

function EnviarConfirmacion() {
    var id = $get(hdnIdInvitacion).value;
    var nom = $get(txtNombre + "_TxtControl").value.trim();
    var txt_nom = $get(txtNombre + "_TxtControl");
    txt_nom.style.backgroundColor = "";
    txt_nom.style.border = "";
    var numAdultos = $get(txtNumAdultos + "_TxtControl1").value;
    var numNinos = $get(txtNumNinos + "_TxtControl1").value;
    var com = $get(txtCom + "_TxtControl").value;
    if (nom != "") {
        if (numAdultos.toString().trim() == "")
            numAdultos = "0";
        if (numNinos.toString().trim() == "")
            numNinos = "0";
        PageMethods.InsertaConfirmacion(id, nom, numAdultos, numNinos, com.toString().trim(), OnSucceededConfirma, OnFailed);
    }
    else {
        alert("Escriba su Nombre o Familia a confirmar");
        txt_nom.style.backgroundColor = "#FFF4F4";
        txt_nom.style.border = "solid 1px red";
        txt_nom.focus();
    }
    return false;
}

function OnSucceededConfirma() {
    $get(txtNombre + "_TxtControl").value = "";
    $get(txtNumAdultos + "_TxtControl1").value = "";
    $get(txtNumNinos + "_TxtControl1").value = "";
    $get(txtCom + "_TxtControl").value = "";
    alert("Se ha confirmado tu asistencia");
}

function OnFailed(error) {
    alert(error.get_message());
}